const { Blog, User } = require("./model.js");
!(async function() {
  const userListWithBlogList = await User.findAndCountAll({
    attributes: ["userName", "nickName"],
    include: [
      {
        model: Blog
      }
    ]
  });
  console.log(
    "userListWithBlogList",
    userListWithBlogList.count,
    JSON.stringify(
      userListWithBlogList.rows.map(user => {
        const userVal = user.dataValues;
        userVal.blogs = userVal.blogs.map(blog => blog.dataValues);
        return userVal;
      })
    )
  );
})();
